import 'package:nyh_motorcade_app/entity/motorcade_entity.dart';

motorcadeEntityFromJson(MotorcadeEntity data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['code'] != null) {
		data.code = json['code'].toString();
	}
	if (json['accountType'] != null) {
		data.accountType = json['accountType'].toString();
	}
	if (json['status'] != null) {
		data.status = json['status'] is String
				? int.tryParse(json['status'])
				: json['status'].toInt();
	}
	if (json['availableAmount'] != null) {
		data.availableAmount = json['availableAmount'] is String
				? double.tryParse(json['availableAmount'])
				: json['availableAmount'].toDouble();
	}
	if (json['subCompanyList'] != null) {
		data.subCompanyList = (json['subCompanyList'] as List).map((v) => v.toString()).toList().cast<String>();
	}
	if (json['subCompanyIdList'] != null) {
		data.subCompanyIdList = (json['subCompanyIdList'] as List).map((v) => v is String
				? int.tryParse(v)
				: v.toInt()).toList().cast<int>();
	}
	return data;
}

Map<String, dynamic> motorcadeEntityToJson(MotorcadeEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['name'] = entity.name;
	data['code'] = entity.code;
	data['accountType'] = entity.accountType;
	data['status'] = entity.status;
	data['availableAmount'] = entity.availableAmount;
	data['subCompanyList'] = entity.subCompanyList;
	data['subCompanyIdList'] = entity.subCompanyIdList;
	return data;
}